
<!DOCTYPE html>
<?php

include_once("inc/constants.inc.php");
include_once("inc/connection.php");
session_start();
if(!isset($_SESSION['login']) || empty($_SESSION['login']) || !isset($_SESSION['email']) || empty($_SESSION['email']) || !isset($_SESSION['user_role']))
	{
		header("Location: login.php?error=invalid-access");
		exit(0);
	}
elseif($_SESSION['user_role']==2)
	{
		header("Location: test.php?error=invalid-access");
		exit(0);
	}
function domainMapper($number){
	switch ($number) {
		case "1":
			return "Java";
			break;
		case "2":
			return "PHP";
			break;
		case "3":
			return ".NET";
			break;
		case "4":
			return "SharePoint";
			break;
		case "5":
			return "iOS";
			break;
		case "6":
			return "ROR";
			break;
		case "7":
			return "Big data";
			break;
		case "8":
			return "Testing";
			break;
	}
}
?>
<html>
	<head>
		<meta charset="utf-8"> 
		<title>Smartek online test | Show Answer Sheet</title>
		<link rel="SHORTCUT ICON" href="img/disp/favicon.png" />	
		<link rel="stylesheet" href="css/bootstrap.css"  type="text/css"/>
	</head>
	<body>
		<?php
			
			$techSubmitted = false;
			$aptitudeSubmitted = false;
			$studentID = $_GET['studentID'];						
			$result1 = mysql_query("SELECT * FROM answer_sheet WHERE StudentID='$studentID'");				
			while($row = mysql_fetch_array($result1))
				{
					if(empty($row['isReset']) || $row['isReset']=="yes")
						{
							$submitted = false;
						}
					elseif($row['isReset']=="no")
						{
							$submitted = true;
						}					
				}
	
		?>
		<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
		<script src="js/bootstrap.js"></script>
		
		<div class="container">
			<a href="index.php"><img src="img/disp/logo.png" alt=""></a>
		</div>
		
		<div class="container">
			<a href="logout.php" class="pull-right">Logout</a>
		</div>		
		<div class="container">
			<hr class="featurette-divider">
		</div>
		<div class="container">
			<div class="row">
				<div class="span12" >				
					<?php
					if($submitted)
					{
						echo "<form action='dashboard.php'>
								<input type='submit' name='backToDashboard' class='btn' value='Back To Dashboard'> <br/>
							</form>";
					}			
					$studentID = $_GET['studentID']; 	
					echo "<h4>Candidate Details:</h4>";
					$result = mysql_query("SELECT * FROM `login_details` WHERE userID='$studentID'");		
					while($row = mysql_fetch_array($result))
					{
						echo "<b>Name: </b>" . $row['UserName'] . "<br/>";
						echo "<b>Gender: </b>" . $row['UserGender'] . "<br/>";
						echo "<b>Mobile No.: </b>" . $row['mobileNo'] . "<br/>";
						echo "<b>Email: </b>" . $row['UserEmail'] . "<br/>";
						echo "<b>Experience:</b> " . $row['experience'] . "<br/>";
						echo "<b>Company: </b>" . $row['company'] . "<br/>";
						echo "<b>Referral: </b>" . $row['referrer'] . "<br/>";
						if($row['employeeName'] != "none")
						{
							echo "<b>Referred by: </b>" . $row['employeeName'] . " ( id # " . $row['employeeId'] . " )<br/>";
						}						
						echo "<b>Location: </b>" . $row['location'] . "<br/>";
						echo "<b>Technology: </b>" . domainMapper($row['domain']) . "<br/>";
						echo "<div class='container'>
								<hr class='featurette-divider'>
							</div>";
						if($submitted)
							{
								$userName = $row['UserName'];
								$QTypeID = $row['domain'];
								$res = mysql_query("SELECT * FROM `question_type` WHERE QTypeID='$QTypeID'");		
								while($req = mysql_fetch_array($res))
								{
									$domain = $req['QType'];
								}								
							}
						else
							{
								echo $row['UserName'] . " has not submitted his answer sheet.<br/><br/><br/>";
							}
					}	
					
					echo "<br/>";
					$result = mysql_query("SELECT * FROM question_table LEFT JOIN answer_sheet on question_table.questionNumber = answer_sheet.QuesID where answer_sheet.StudentID = '$studentID' && answer_sheet.isReset = 'no' order by question_table.typeId");	
					$i = 1;
					while($row = mysql_fetch_array($result))
					{	
						echo "<b>Question No." . $i++ . ". ";
						echo $row['question'] . " </b><br/>" ;
					?>		
						A. <?php echo $row['optionOne'] . "<br/>"; ?>
						B. <?php echo $row['optionTwo'] . "<br/>"; ?>
						C. <?php echo $row['optionThree'] . "<br/>"; ?>
						D. <?php echo $row['optionFour'] . "<br/>"; ?>						
						<?php 
							if($row['Answer']==$row['correctOption']) 
							{
								if($row['Answer'] == "a")
									{
										echo "<font color='green'> <h5>Answered : ". strtoupper($row['Answer']) . ". " . $row['optionOne'] . " </h5></font><br/>";
									}
								elseif($row['Answer'] == "b")
									{
										echo "<font color='green'> <h5>Answered : ". strtoupper($row['Answer']) . ". " . $row['optionTwo'] . "</h5></font><br/>";
									}
								elseif($row['Answer'] == "c")
									{
										echo "<font color='green'><h5> Answered : ". strtoupper($row['Answer']) . ". " . $row['optionThree'] . "</h5></font><br/>";
									}
								elseif($row['Answer'] == "d")
									{
										echo "<font color='green'> <h5>Answered : ". strtoupper($row['Answer']) . ". " . $row['optionFour'] . "</h5></font><br/>";
									}
							}
							else
							{
								if($row['Answer'] == "a")
									{echo "<font color='red'><h5> Answered : ". strtoupper($row['Answer']) . ". " . $row['optionOne'] . "(Wrong)</h5></font>";}
								elseif($row['Answer'] == "b")
									{echo "<font color='red'> <h5>Answered : ". strtoupper($row['Answer']) . ". " . $row['optionTwo'] . "(Wrong)</h5></font>";}
								elseif($row['Answer'] == "c")
									{echo "<font color='red'> <h5>Answered : ". strtoupper($row['Answer']) . ". " . $row['optionThree'] . "(Wrong)</h5></font>";}
								elseif($row['Answer'] == "d")
									{echo "<font color='red'><h5> Answered : ". strtoupper($row['Answer']) . ". " . $row['optionFour'] . "(Wrong)</h5></font>";}
								echo "<h5><b>Correct Answer is : </b>" . $row['correctOption'] . "</h5>";
							}
						?>	
						<br/><br/><br/><br/>
				<?php
					}	
				?>
					<form action='dashboard.php'>
						<input type='submit' name='backToDashboard' class='btn' value='Back To Dashboard'> <br/>
					</form>
				</div>
			</div>
		</div>	
		<div class="container marketing">
			<div class="container">
				<hr class="featurette-divider">
			</div>
			<footer>
				<p>&copy; 2014 SCS &middot; </p>
			</footer>
		</div>
	</body>
</html>

	
	
	
	
	
	





<?php
/*
include_once("inc/constants.inc.php");
include_once("inc/connection.php");
session_start();
if(!isset($_SESSION['login']) || empty($_SESSION['login']) || !isset($_SESSION['email']) || empty($_SESSION['email']) || !isset($_SESSION['user_role']))
	{
		header("Location: login.php?error=invalid-access");
		exit(0);
	}
elseif($_SESSION['user_role']==2)
	{
		header("Location: test.php?error=invalid-access");
		exit(0);
	}

?>
<html>
	<head>
		<meta charset="utf-8"> 
		<title>Smartek online test | Show Answer Sheet</title>
		<link rel="SHORTCUT ICON" href="img/disp/favicon.png" />	
		<link rel="stylesheet" href="css/bootstrap.css"  type="text/css"/>
	</head>
	<body>
		<?php
			
			$techSubmitted = false;
			$aptitudeSubmitted = false;
			$studentID = $_GET['studentID'];						
			$result1 = mysql_query("SELECT * FROM answer_sheet WHERE StudentID='$studentID'");				
			while($row = mysql_fetch_array($result1))
				{
					if(empty($row['isReset']))
						{
							$aptitudeSubmitted = true;
							$techSubmitted = true;
						}
					elseif($row['isReset']=="no")
						{
							if(isset($row['typeId']))
							{
								if($row['typeId'] == 1)
									{
										$aptitudeSubmitted = true;
									}
								if($row['typeId'] == 2)
									{
										$techSubmitted = true;
									}				
							}						
						}					
				}
	
		?>
		<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
		<script src="js/bootstrap.js"></script>
		
		<div class="container">
			<a href="index.php"><img src="img/disp/logo.png" alt=""></a>
		</div>
		
		<div class="container">
			<a href="logout.php" class="pull-right">Logout</a>
		</div>
		
		
		<div class="container">
			<hr class="featurette-divider">
		</div>
		
		

		<div class="container">
			<div class="row">
				<div class="span12" > <!--pagination-centered-->
				
					<?php
					if($aptitudeSubmitted || $techSubmitted)
						{
							echo "<form action='dashboard.php'>
									<input type='submit' name='backToDashboard' class='btn' value='Back To Dashboard'> <br/>
								</form>";
						}
					?>
				
				
<?php
			
					$studentID = $_GET['studentID']; 	
					$result = mysql_query("SELECT * FROM `login_details` WHERE userID='$studentID'");		
					while($row = mysql_fetch_array($result))
						{
							if($aptitudeSubmitted || $techSubmitted)
								{
									echo "<h3>Answer Sheet of " . $row['UserName']. " ( Roll No. - ". $row['UserRollNo'] . ")</h3>";
								}
							else
								{
									echo $row['UserName'] . " has not submitted his answer sheet.<br/><br/><br/>";
								}
						}
	
for($typeId = 1; $typeId <=2 ; $typeId++)
	{
	
	$result = mysql_query("SELECT * FROM question_table LEFT JOIN answer_sheet on question_table.questionNumber = answer_sheet.QuesID where answer_sheet.StudentID = '$studentID' && answer_sheet.typeId='$typeId' && answer_sheet.isReset = 'no' order by question_table.typeId");

	
	if($typeId == 1 && $aptitudeSubmitted)
		{
			echo "<h4>Aptitude Questions</h4>";	
		}
	elseif($typeId == 2 && $techSubmitted)
		{
			echo "<br/><h4>Computer Science Questions</h4>";	
		}
	$i = 1;
	while($row = mysql_fetch_array($result))
	{	
		echo "<b>" . $i++ . ". ";
		echo $row['question'] . " </b><br/>" ;
?>		

		a. <?php echo $row['optionOne'] . "<br/>"; ?>
		b. <?php echo $row['optionTwo'] . "<br/>"; ?>
		c. <?php echo $row['optionThree'] . "<br/>"; ?>
		d. <?php echo $row['optionFour'] . "<br/>"; ?>
		
		<?php 
			if($row['Answer']==$row['correctOption']) 
				{
					if($row['Answer'] == "a")
						{
							echo "<font color='green'> Answered : " . $row['optionOne'] . " </font><br/>";
						}
					elseif($row['Answer'] == "b")
						{
							echo "<font color='green'> Answered : " . $row['optionTwo'] . "</font><br/>";
						}
					elseif($row['Answer'] == "c")
						{
							echo "<font color='green'> Answered : " . $row['optionThree'] . "</font><br/>";
						}
					elseif($row['Answer'] == "d")
						{
							echo "<font color='green'> Answered : " . $row['optionFour'] . "</font><br/>";
						}
				}
			else
				{
					if($row['Answer'] == "a")
						{
							echo "<font color='red'> Answered : " . $row['optionOne'] . " - Wrong</font><br/>";
						}
					elseif($row['Answer'] == "b")
						{
							echo "<font color='red'> Answered : " . $row['optionTwo'] . " - Wrong</font><br/>";
						}
					elseif($row['Answer'] == "c")
						{
							echo "<font color='red'> Answered : " . $row['optionThree'] . " - Wrong</font><br/>";
						}
					elseif($row['Answer'] == "d")
						{
							echo "<font color='red'> Answered : " . $row['optionFour'] . " - Wrong</font><br/>";
						}
					echo "<b>Correct Answer is : </b>" . $row['correctOption'];
				}
		?>

				
		
		<br/><br/>
	


<?php
	}
	}
	
?>
		<form action='dashboard.php'>
			<input type='submit' name='backToDashboard' class='btn' value='Back To Dashboard'> <br/>
		</form>
			</div>
		</div>
	</div>

		
		<div class="container marketing">
      <!-- FOOTER -->
		<div class="container">
			<hr class="featurette-divider">
		</div>
      <footer>
       <p>&copy; 2014 SCS &middot; </p>
      </footer>

    </div><!-- /.container -->
	</body>
</html>
<?php
	*/
	?>
	
	
	
	
	
	
